<?php

namespace App\Http\Controllers\Wx;

use App\Helpers\ResponseData;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Miniprograme\AppCodeController;
use Illuminate\Http\Request;

class CustomMenuController extends WxCommonController
{
    use ResponseData;
    //获取菜单
    public function list(){
        $current = $this->wx->menu->current();
        return $this->success($current);
    }
    //创建菜单
    public function create(){
        $buttons = [
            [
                "type" => "miniprogram",
                'name'=>'邦拓租车小程序',
                'url'=>'https://mp.weixin.qq.com',
                'appid'=>'wxf13c900b020f151b',
                'pagepath'=>'pages/index/index'
            ]
//            [
//                "type" => "click",
//                "name" => "今日歌曲",
//                "key"  => "V1001_TODAY_MUSIC"
//            ],
//            [
//                "name"       => "菜单",
//                "sub_button" => [
//                    [
//                        "type" => "view",
//                        "name" => "搜索",
//                        "url"  => "http://www.soso.com/"
//                    ],
//                    [
//                        "type" => "view",
//                        "name" => "视频",
//                        "url"  => "http://v.qq.com/"
//                    ],
//                    [
//                        "type" => "click",
//                        "name" => "赞一下我们",
//                        "key" => "V1001_GOOD"
//                    ],
//                ],
//            ],
        ];
        $data = $this->wx->menu->create($buttons);
        dd($data);

    }
    public function delete(){
        $data = $this->wx->menu->delete(); // 全部
        return $this->success($data);
    }
    //生成小程序码
    public function createCodeB(Request $request){
        if($request->filled('num')){
            $code = new AppCodeController();
            $sence = $request->num;
            $option = [
                'width'=>1280,
                'page'  => 'pages/index/index',
                'is_hyaline'=>true
            ];
            $data = $code->appCodeB($sence,$option);
            return $this->success($data);
        }

    }
}
